package com.itheima.a05threadmethod2;

public class ThreadDemo1 {
    public static void main(String[] args) {
        //研究线程的优先级

        //谁的优先级更高，谁抢到CPU的执行权的概率就更大

        //创建要执行任务的对象
        MyRunnable mr = new MyRunnable();
        //创建线程对象
        Thread t1 = new Thread(mr);
        Thread t2 = new Thread(mr);
        //设置线程的名称
        t1.setName("线程1");
        t2.setName("线程2");
        //设置线程的优先级
        t1.setPriority(1);
        t2.setPriority(10);
        //启动线程
        t1.start();
        t2.start();
    }
}
